package com.concurrency.example.blockQueue;

import sun.dc.pr.PRError;

import java.io.File;
import java.util.List;
import java.util.concurrent.BlockingDeque;

/**
 * @Auther: xuwei
 * @Date: 2018/11/29 16:25
 */
public class Indexer implements Runnable{
    private final BlockingDeque<File> queue;
    private final List<String> index;

    public Indexer(BlockingDeque<File> queue, List<String> index) {
        this.queue = queue;
        this.index = index;
    }

    @Override
    public void run() {
        try {
            while (true) {
                index.add(queue.take().getName());
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
